package com.zhaotianhao.check.comboserver.api;

import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zhaotianhao.check.comboserver.common.JsonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @Author Z-7
 * @Date 2022/4/1
 */
@RestController
@RequestMapping("group")
public class GroupController {
    @GetMapping("getAll")
    public JsonResult getAll(){
        /*Map<String, Object> map = new HashMap<>();
        map.put("id",1);*/
        JSONArray objects = null;
        try {
            String s = HttpRequest.get("http://192.168.127.142:8083/group/getGroups")
                    .header("uuid", UUID.randomUUID().toString())
                    .timeout(10000)
                    .execute().body();
            objects = JSONObject.parseArray(s);
        } catch (Exception e) {
            String s = HttpRequest.get("http://192.168.127.142:8083/group/getGroups")
                    .timeout(10000)
                    .execute().body();
            objects = JSONObject.parseArray(s);
        }
        return JsonResult.successd(objects);
    }
}
